package com.hjj.concurrence.syncBlock.t2;

public class ObjectService {
    public void serviceMethod() {
        synchronized (this) {
            try {
                System.out.println("begin time=" + System.currentTimeMillis());
                Thread.sleep(2000);
                System.out.println("end end=" + System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        ObjectService objectService = new ObjectService();
        ThreadA a = new ThreadA(objectService);
        a.setName("a");
        a.start();

        ThreadB b = new ThreadB(objectService);
        b.setName("b");
        b.start();
    }
}
